<template>
  <div v-loading="loading" class="followup_wrapper">
    <el-row>
      <el-col class="write" :span="12">
        <div class="info">
          <el-form ref="followUp" label-width="100px" :model="followUp">
            <el-form-item class="label_title" label="审核：" prop="status">
              <el-radio-group v-model="followUp.status">
                <el-radio :label="2">通过</el-radio>
                <el-radio :label="3">拒绝</el-radio>
              </el-radio-group>

            </el-form-item>
            <el-form-item label="报名岗位：">
              <el-input v-model="rows.career_name"   :disabled="true"  />
            </el-form-item>

            <el-form-item label="描述：" prop="desc">
              <el-input v-model="followUp.desc" :rows="11" type="textarea" :disabled="disabled_state" maxlength="250" show-word-limit />
            </el-form-item>

            <el-form-item>
              <el-button type="primary" :disabled="disabled_state" @click.native="reviewLog('followUp')">立即提交</el-button>
            </el-form-item>
          </el-form>
        </div>
      </el-col>
      <el-col class="history" :span="12">
        <div class="title">
          <span class="text">历史审核</span>
          <div class="total">
            共有
            <span class="sum">{{ total }}条</span>
            记录
          </div>
        </div>
        <div class="history_list">
          <div class="history_item">
            <el-table
                ref="filterTable"
                :data="record"
                style="width: 100%">
                <el-table-column
                  prop="id"
                  label="序号"
                  sortable
                  width="80"
                >
                </el-table-column>

                <el-table-column
                  prop="tag"
                  label="状态"
                  width="100">
                  <template slot-scope="scope">
                    <el-tag :type="scope.row.review_class_status"
                      disable-transitions> {{scope.row.status_txt}}</el-tag>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="msg"
                  label="原因">
                </el-table-column>
                <el-table-column
                  prop="create_time_formate"
                  label="提审日期"
                  sortable
                  width="180"
                >
                </el-table-column>
                <el-table-column
                  prop="review_time_formate"
                  label="审核日期"
                  sortable
                  width="180"
                >
                </el-table-column>
              </el-table>
          </div>
        </div>
        <div v-if="listParams.total >=10" class="pagination">
          <el-pagination
            background
            :current-page="listParams.page"
            :page-sizes="[10, 20, 50, 100]"
            layout="total, sizes, prev, pager, next, jumper"
            :page-size="listParams.page_size"
            :total="total"
            @size-change="handlePageSize"
            @current-change="handleCurrentSize"
          />
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { doReview ,reviewList,examUserInfo} from '@/api/kaowu/exam'

export default {
  name: 'FollowUpRecord',
  props: ['id','rows'],
  data () {
    return {
      loading: false,
      disabled_state: false,
      listParams: {
        page: 1,
        page_size: 10,
        total: 0

      },
      pickerOptions: {
        selectableRange: (() => {
          return `00:00:00 - 23:59:59`
        })(),
        disabledDate(time){
          return time.getTime() < Date.now() - 8.64e7
        }
      },
      followUp: {
        status: '',
        desc: '',
      },
      visitStatusList: [
        { label: '当面拜访', value: '1' },
        { label: '电话拜访', value: '2' },
        { label: '网络拜访', value: '3' },
        { label: '其它拜访', value: '0' }
      ], // 跟进方式列表
      record: [],
      total: 0,
      upload_url: '',
      headerObj: '',
      currentNav: '',
      user_id: ''
    }
  },
  created() {
    this.init()
    console.log(this.rows)
  },
  methods: {

    init(){
      // this.userInfoDetails()
      this.followUpList()
    },

    userInfoDetails(){
      examUserInfo({ 'id': this.id})
        .then(res => {
          this.details = res.data.info
        }).catch(() => {

        })
    },

    followUpList(){
      this.loading = true
      reviewList({ 'id': this.id, 'page': this.listParams.page, 'pagesize': this.listParams.page_size })
        .then(res => {
          if (res.data.items.length > 0){
            this.record = res.data.items

            this.total = res.data.total
            this.listParams.total = res.data.total
            this.listParams.page = res.data.total_page
          }
          this.loading = false
        }).catch(() => {
          this.loading = false
        })
    },
    reviewLog(formName){
      if (this.submitLoading === true) {
        return false
      }
      this.submitLoading = true
      let followUp = this.followUp;
      followUp.id = this.id
      doReview(followUp)
        .then(res => {
          if (res.code == 200){
            this.$message.success(res.message)
            this.$emit('click-event', res)
            this.followUpList()
          } else {
            this.$message.error(res.message)
          }
          this.followUp.status = ''
          this.followUp.desc = ''
          this.submitLoading = false
        }).catch(() => {
          this.submitLoading = false
        })
    }

  }
}
</script>

<style lang="scss" scoped>
::v-deep .el-upload__text{
  height: 25px;
}
::v-deep .upload-demo{
  width: 100%;
}
::v-deep .el-upload{
  width: 100%;
}
::v-deep .el-upload-dragger{
  width: 100%;
}
::v-deep .el-col-12{
  height: 100vh;
}
::v-deep .el-form-item{
  margin-bottom: 20px;
}
::v-deep .el-form-item__label{
  font-size: 14px;
  color: #606266;
  font-weight:normal;
}
p{
  margin: 0;
  padding: 0;
  line-height: 24px;
}
.followup_wrapper{
  height: calc(100vh - 194px - 52px);
  overflow-y: auto;
  background: #fff;
  margin-top: 1px;
}
::v-deep .el-dialog__body{
  padding: 0;
}
.write{
  padding-top: 15px;
  border-right: 1px solid #ebeef5;
  .info{
    padding: 10px 30px;
    .el-select{
      width: 100%;
    }
    .customer{
      display: inline-block;
      padding: 1px 4px;
      height: 21px;
      border-radius: 2px;
      text-align: center;
      line-height: 21px;
      font-size: 12px;
      margin-right: 10px;
    }
    .add_tag{
      padding: 3px 10px;
      font-size: 12px;
    }
    .rule_tag{
      margin-left: 10px;
    }
  }
}
.history{
  .title{
    height: 50px;
    line-height: 50px;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid #ebeef5;
    .text{
      color: #333;
      font-weight: 600;
    }
    .total{
      color: #666;
      font-weight: 400;
      .sum{
        color: #6e86b1;
      }
    }
  }
  .history_list{
    padding: 0 20px;
    height: 600px;
    overflow-x: auto;
    &::-webkit-scrollbar{
      width: 8px;
      background: #fff;
    }
    &::-webkit-scrollbar-thumb{
      width: 8px;
      height: 30px;
      border-radius: 10px;
      background: #DEDEE4;
    }
    .history_item{
      display: flex;
      border-bottom: 1px dotted #dcdfe6;
      padding: 20px 0;
      width: 100%;
      .user{
        width: 40px;
        height:40px ;
        display: flex;
        border-radius: 50%;
        background: #4a88f7;
        justify-content: center;
        align-items: center;
        margin: 0 20px 20px 0;
        color: #fff;
      }
      .info{
        flex: 1;
        .followup{
          display: flex;
          justify-content: space-between;
          align-items: center;
          margin-bottom: 16px;
          padding-top: 6px;
          &:hover .edit{
            display: block;
          }
          .text{
            color: #333;
            font-size: 15px;
            flex: 1;
            max-width: 200px;
            text-overflow: ellipsis;
            overflow: hidden;
            white-space:nowrap;
            .color{
              color: #6e86b1;
              font-weight: 600;
            }
          }
          .text_right{
            display: flex;
          }
          .edit{
            display: none;
            margin-right: 15px;
            height: 14px;
            font-size: 14px;
            font-weight: 400;
            color: #0078ff;
            cursor: pointer;
          }
          .time{
            font-size: 14px;
            color: #999;
          }
        }
        .content{
          background-color: #f7f7f7;
          font-size: 14px;
          color: #333;
          padding: 16px;
          font-weight: 400;
          .img {
            display: inline-block;
            margin: 20px 10px 0px 0px;
          }
        }
      }
    }
  }
  .pagination{
    text-align: center;
    padding: 15px 20px 15px 0;
  }
}
.dialog_footer{
  width: 100%;
  display: inline-block;
  text-align: left;
  padding-left: 83px;
}
.dialog_footer2{
  width: 100%;
  display: inline-block;
  text-align: left;
}
</style>

